<template>
    <div id="index">
        <Header></Header>
        <div class="container">
            <Nav
                :is-collapse="isCollapse"
                :class="{'nav-collapse':isCollapse}"
            ></Nav>
            <div
                class="mainbody"
                :class="{'mainbody-collapse':isCollapse}"
            >
                <div class="pages">
                    <div class="center is-collapse">
                        <div
                            class="pointer center"
                            :title="setCollapseTitle"
                            @click="collapseFun"
                        >
                            <img
                                src="~assets/images/collapse.png"
                                alt=""
                                srcset=""
                            >
                        </div>
                    </div>
                    <router-view/>
                </div>
                <Footer></Footer>
            </div>
        </div>
    </div>
</template>

<script>
    import Header from 'cmpts/Header';
    import Footer from 'cmpts/Footer';
    import Nav from 'cmpts/Nav';
    export default {
        components: {
            Header,
            Footer,
            Nav
        },
        data () {
            return {
                isCollapse: false
            };
        },
        computed: {
            setCollapseTitle () {
                return this.isCollapse ? '展开' : '收起';
            }
        },
        methods: {
            collapseFun () {
                this.isCollapse = !this.isCollapse;
            }
        }
    };
</script>

<style lang="less" scoped>
#index {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    .container {
        flex-grow: 1;
        position: relative;
        &>.mainbody{
            display: flex;
            flex-direction: column;
            height: 100%;
            padding-left: 230px;
            transition: all .2s;
            .pages{
                position: relative;
                width: 100%;
                height: 0;
                padding: 20px;
                flex-grow: 1;
                background-color: #f2f3f7;
                overflow: hidden;
                .is-collapse{
                    position: absolute;
                    left:0;top:0;
                    width: 20px;
                    height: 100%;
                    div{
                        padding: 4px;
                        margin-left: -4px;
                    }
                }
            }
        }
        .mainbody-collapse{
            padding-left: 64px;
        }
        .nav-collapse{
            width: 64px;
        }
    }
}
</style>
